from pydantic import conint, BaseModel, confloat, Field, constr


class RmConfig(BaseModel):
    commit: bool = True
    pre_amp_neg: confloat() = -0.9
    out_amp_neg: confloat() = -2
    ten_v: bool = False
    pre_amp: bool = False
    read_back: conint(ge=0) = 0
    actual_rx_frequency: conint(ge=1) = 1_750_000
    actual_tx_frequency: conint(ge=1) = 1_330_000
    rx_frequency: conint(ge=6_230_000_000, le=7_125_000_000) = 6_680_000_000
    tx_frequency: conint(ge=6_230_000_000, le=7_125_000_000) = 7_020_000_000

    class Config:
        validate_assignment = True


class RmTelemetry(BaseModel):
    temperature: confloat() = 0.0
    voltage_28v: confloat() = 0.0
    voltage_8v: confloat() = 0.0
    voltage_5v: confloat() = 0.0
    preamp_current: confloat() = 0.0
    pa_current: confloat() = 0.0
    rf_direct_detector_out: confloat() = 0.0
    rf_rev_detector_out: confloat() = 0.0
    rx_synth_lock: constr() = ''
    tx_synth_lock: constr() = ''
    current_rm_module: confloat() = 0.0
    raw_message: str = ''

    class Config:
        validate_assignment = True


class VcoConfig(BaseModel):
    actual_rx_frequency: conint(ge=0) = 1
    actual_tx_frequency: conint(ge=0) = 1
    rx_center_frequency: conint(ge=0) = 0
    tx_center_frequency: conint(ge=0) = 0
    r_div: conint(ge=0) = 0
    n_div_rx_round: conint(ge=0) = 0
    n_div_tx_round: conint(ge=0) = 0
    f_pfd: conint(ge=0) = 0
